import os

def get_files_with_extensions(directory, extensions):
    files = []
    for root, _, filenames in os.walk(directory):
        for filename in filenames:
            file_extension = os.path.splitext(filename)[1]
            if file_extension.lower() in extensions:
                files.append(os.path.join(root, filename))
    return files

include = 'include/'
src = 'src/'
extensions = ['.ts', '.tsx']

files_includes = get_files_with_extensions(include, extensions)
files_srcs = get_files_with_extensions(src, extensions)
with open('output.txt', 'w', encoding='utf-8') as w:
    for file in files_includes:
        with open(file, 'r') as f:
            w.write(f"// ФАЙЛ: {file.split('/')[1]}\n {f.read()}\n")
            
            print(file)
    for file in files_srcs:
        with open(file, 'r') as f:
            w.write(f"// ФАЙЛ: {file.split('/')[1]}\n {f.read()}\n")
            
            print(file)
    